﻿@model List<eBusiness.Models.Category>
<style type="text/css">
    #SubMenuDiv { margin-left: 10px; position: relative;left: 200px}
    #SubMenuDiv table { border: 0 !important; padding: 0 !important; margin: 0 !important; background: orangered; border: 1px solid #fff; }
    #SubMenuDiv table td { vertical-align: top; text-align: left; border: none; margin: 0; padding: 0; }
    #SubMenuDiv table tr { margin: 0; padding: 0; }
    .sub_menu a {text-decoration: none; color: #fff}
</style>
@if (Model.Any())
{
    var pivot = Model.Count();
    if (pivot % 2 == 0)
    {
        pivot = pivot / 2;
    }
    else
    {
        pivot = pivot / 2 + 1;
    }

    <div id="SubMenuDiv">
        <table id="sub-menu-table" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <ul class="sub_menu">
                        @for (int i = 0; i < pivot / 2 + 1; i++)
                        {
                            <li class="sub_menu_item">
                                <a href="@Url.Action("Index", "Product", new { categoryId = Model[i].ID })"><div class="menu_link">@Model[i].Name</div></a>
                            </li>
                        }
                    </ul>
                </td>
                <td>
                    <ul class="sub_menu">
                        @for (int i = pivot; i < Model.Count(); i++)
                        {
                            <li class="sub_menu_item">
                                <a href="@Url.Action("Index", "Product", new { categoryId = Model[i].ID })"><div class="menu_link">@Model[i].Name</div></a>
                            </li>
                        }
                    </ul>
                </td>
            </tr>
        </table>
    </div>
}